// sudo npm install webpack html-webpack-plugin clean-webpack-plugin style-loader css-loader less-loader less url-loader file-loader vue vue-router vue-loader vue-template-compiler babel-loader babel-preset-es2015 babel-core babel-plugin-transform-runtime 
// sudo  npm install webpack-dev-server -g
//生成HTML
var html = require("html-webpack-plugin");
//删除文件
var clean = require("clean-webpack-plugin");

var webpack = require("webpack");
module.exports={
	entry:"./app/app.js",
	output:{
		path:__dirname+"/www",
		filename:"js/bundle.js"
	},
	module:{//模块
		loaders:[
			{
				test:/\.css$/,
				loader:"style-loader!css-loader!less-loader"
			},
			{
				test:/\.(png|jpe?g|gif)$/,
				loader:"url-loader?limit=5000&name=images/[name]-[hash:4].[ext]"
			},
			{
				test:/\.vue$/,
				loader:"vue-loader"
			}	
		]
	},
	plugins:[
		new html({
			title:"生活一家",
			template:__dirname+"/app/index.html",
			filename:"index.html"
		}),
		new clean(["www"]),
		// new webpack.optimize.UglifyJsPlugin({
		// 	compress:{
		// 		warnings:false//取消报错提示
		// 	}
		// })//压缩代码
		new webpack.ProvidePlugin({//设置全局变量
            // React: 'react',
            // ReactDOM: 'react-dom',
        })//直接加载到全局不需要require()
	],
	devServer: {//自动刷新
        contentBase:"./www",
        inline: true,//默认false
        port: 8088
        //运行  webpack-dev-server
    },
	resolve:{
        alias: {
            'vue$': 'vue/dist/vue.common.js',
        }
    }

}